package com.test.utils;

import com.test.model.TemperaturePanelCurrentData;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.Map;

/**
 * Created by ZZF on 2017/7/7.
 */
public  class TemperaturePanelCurrentGenerate {

    public static TemperaturePanelCurrentData Generate(TemperaturePanelCurrentData temperaturePanelCurrentData) {


        Map<String, String> configMap = BaseUtils.inputConfig();

        double temperatureMax = Double.valueOf(configMap.get("Temperature_Max"));
        double temperatureMin = Double.valueOf(configMap.get("Temperature_Min"));

        //保留两位小数
        DecimalFormat df = new DecimalFormat("#.00");

        double temperature = (temperatureMin + Math.random() * (temperatureMax - temperatureMin));

        BigDecimal newTemperature = BaseUtils.getBigDecimal(df.format(temperature));

        temperaturePanelCurrentData.setTemperature(newTemperature);

        temperaturePanelCurrentData.setPlanTime(new Date());

        return temperaturePanelCurrentData;
    }

}


